unit GLButton;

interface

uses Classes,GlScene,GLHUDObjects,GLControl,GLCrossPlatform, GLWindowsFont, BaseClasses;

type
  TGLButton = class(TGLControl)
  protected
    fHUDText : TGLHUDText;
    procedure SetText(aText : string);
    function GetText: string;
    Procedure fMouseEvent(aSender: TGLControl; aOldState, aNewState: TGLCtrlMouseState); override;
    Procedure SelfInit; override;
    Procedure DoProgress(const progressTime: TProgressTimes); override;
  public
    procedure SetFont(aFont: TGLWindowsBitmapFont);
    procedure SetPosition(xPos, yPos: Single);
    property Text : string read GetText write SetText;
  end;
  TGLButtonClass = class of TGLButton;

implementation
uses Dialogs;

{ TGLButton }

procedure TGLButton.DoProgress(const progressTime: TProgressTimes);
begin
  inherited;
   fHUDText.Position:=Self.Position;
   fHUDText.Rotation:=Self.Rotation;
end;

procedure TGLButton.fMouseEvent(aSender: TGLControl; aOldState,
  aNewState: TGLCtrlMouseState);
begin
  inherited;
end;

function TGLButton.GetText: string;
begin
  result:=fHUDText.Text;
end;

procedure TGLButton.SelfInit;
begin
  inherited;
  fHUDText:= TGLHUDText.CreateAsChild(Self);
  fHUDText.Alignment := taCenter;
  fHUDText.Layout := tlCenter;
end;

procedure TGLButton.SetFont(aFont: TGLWindowsBitmapFont);
begin
  aFont.Font.Size:=aFont.Font.Size+2;
  fHUDText.BitmapFont:=aFont;
end;

procedure TGLButton.SetPosition(xPos, yPos: Single);
begin
  inherited;
  fHUDText.Position.SetPoint(xPos,yPos,0);
end;

procedure TGLButton.SetText(aText: string);
begin
  fHUDText.Text:=aText;
end;

end.
